/**
 * 
 */
package com.music.service.urls.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.music.service.urls.beans.Url;
import com.music.service.urls.constants.UrlAccessState;
import com.music.service.urls.constants.UrlState;

/**
 * @author asanthan
 *
 */
public class UrlMapper implements RowMapper {
	/* (non-Javadoc)
	 * @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
	 */
	public Object mapRow(ResultSet pResultSet, int pArg1) throws SQLException {
		Url url = new Url();
		url.setUrlId(pResultSet.getLong("url_id"));
		url.setUrlPath(pResultSet.getString("url_path"));
		url.setState(UrlState.getUrlState(pResultSet.getString("state")));
		url.setSongId(pResultSet.getLong("song_id"));
		url.setOwnerId(pResultSet.getLong("created_member_id"));
		url.setAccessState(UrlAccessState.getUrlAccessState(pResultSet.getString("valid_url")));
		url.setCreationDate(pResultSet.getDate("creation_date"));
		return url;
	}

}
